package com.ruoyi.web.controller.dict;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dict.domain.TDictWorkOrderStatus;
import com.ruoyi.dict.service.ITDictWorkOrderStatusService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 维修单状态字典Controller
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/system/work/status")
public class TDictWorkOrderStatusController extends BaseController
{
    @Autowired
    private ITDictWorkOrderStatusService tDictWorkOrderStatusService;

    /**
     * 查询维修单状态字典列表
     */
    @PreAuthorize("@ss.hasPermi('system:status:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDictWorkOrderStatus tDictWorkOrderStatus)
    {
        startPage();
        List<TDictWorkOrderStatus> list = tDictWorkOrderStatusService.selectTDictWorkOrderStatusList(tDictWorkOrderStatus);
        return getDataTable(list);
    }

    /**
     * 导出维修单状态字典列表
     */
    @PreAuthorize("@ss.hasPermi('system:status:export')")
    @Log(title = "维修单状态字典", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TDictWorkOrderStatus tDictWorkOrderStatus)
    {
        List<TDictWorkOrderStatus> list = tDictWorkOrderStatusService.selectTDictWorkOrderStatusList(tDictWorkOrderStatus);
        ExcelUtil<TDictWorkOrderStatus> util = new ExcelUtil<TDictWorkOrderStatus>(TDictWorkOrderStatus.class);
        util.exportExcel(response, list, "维修单状态字典数据");
    }

    /**
     * 获取维修单状态字典详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:status:query')")
    @GetMapping(value = "/{code}")
    public AjaxResult getInfo(@PathVariable("code") String code)
    {
        return success(tDictWorkOrderStatusService.selectTDictWorkOrderStatusByCode(code));
    }

    /**
     * 新增维修单状态字典
     */
    @PreAuthorize("@ss.hasPermi('system:status:add')")
    @Log(title = "维修单状态字典", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDictWorkOrderStatus tDictWorkOrderStatus)
    {
        return toAjax(tDictWorkOrderStatusService.insertTDictWorkOrderStatus(tDictWorkOrderStatus));
    }

    /**
     * 修改维修单状态字典
     */
    @PreAuthorize("@ss.hasPermi('system:status:edit')")
    @Log(title = "维修单状态字典", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDictWorkOrderStatus tDictWorkOrderStatus)
    {
        return toAjax(tDictWorkOrderStatusService.updateTDictWorkOrderStatus(tDictWorkOrderStatus));
    }

    /**
     * 删除维修单状态字典
     */
    @PreAuthorize("@ss.hasPermi('system:status:remove')")
    @Log(title = "维修单状态字典", businessType = BusinessType.DELETE)
	@DeleteMapping("/{codes}")
    public AjaxResult remove(@PathVariable String[] codes)
    {
        return toAjax(tDictWorkOrderStatusService.deleteTDictWorkOrderStatusByCodes(codes));
    }
}